from webapp.Lift.lift import Lift

def main():
    # Initialize the Lift instance
    # port = input("Enter the serial port (e.g., COM3): ")
    port = '/dev/ttyUSB0' 
    lift = Lift(port=port)

    while True:
        print("\nSelect a command:")
        print("1. 一号位")
        print("2. 二号位")
        print("3. 三号位")
        print("4. 上升")
        print("5. 下降")
        print("6. 复位")
        print("7. 上升停止")
        print("8. 下降停止")
        print("9. 退出")

        choice = input("Enter your choice: ")

        try:
            if choice == '1':
                lift.move_to_position_one()
                print("Moved to 一号位")
            elif choice == '2':
                lift.move_to_position_two()
                print("Moved to 二号位")
            elif choice == '3':
                lift.move_to_position_three()
                print("Moved to 三号位")
            elif choice == '4':
                lift.move_up()
                print("Lift is moving up")
            elif choice == '5':
                lift.move_down()
                print("Lift is moving down")
            elif choice == '6':
                lift.reset()
                print("Lift has been reset")
            elif choice == '7':
                lift.stop_moving_up()
                print("Stopped moving up")
            elif choice == '8':
                lift.stop_moving_down()
                print("Stopped moving down")
            elif choice == '9':
                print("Exiting...")
                break
            else:
                print("Invalid choice. Please try again.")
        except Exception as e:
            print(f"Error: {e}")

if __name__ == "__main__":
    main()
